#pragma once

#include "../TinyXML2/tinyxml2.h"

#ifdef _DEBUG
	#pragma comment( lib, "tinyxml2d.lib" )
#else
	#pragma comment( lib, "tinyxml2.lib" )
#endif

namespace tinyxml2 {
	class XMLNode;
}

typedef std::map<int,int> MAP_SESSION_INFOS;

struct Action
{
    std::string		m_actionName;
    size_t			m_loop;
    size_t			m_interval;
};
typedef std::vector<Action*> VECTOR_ACTION;

struct Actions
{
	unsigned long	m_id;
    size_t			m_loop;
    size_t			m_interval;

	VECTOR_ACTION	m_Actions;
};
typedef std::map<unsigned long,Actions*> MAP_ACTIONS;

////////////////////////////////////////////////////////////////////////
class CRuleModel
{
public:
	CRuleModel(void);
	~CRuleModel(void);

	static CRuleModel*	s_pInstance;
	static CRuleModel*	GetInstance();

public:
	static std::string s_ServerURL;

	static int	s_division;
	static int	s_division_capacity;

private:
	MAP_SESSION_INFOS			m_mapSessionInfo;
	MAP_ACTIONS					m_ActionRules;

	MAP_ACTIONS					m_groupActions;

public:
	bool Initialize();

private:
	bool ParseEnvironmentInformation( tinyxml2::XMLNode*& info );
	bool ParseActionRules( tinyxml2::XMLNode*& node );
	bool ParseSessionBehaviors( tinyxml2::XMLNode*& node );

public:
	size_t GetSessionGroup( MAP_SESSION_INFOS::iterator& it );
	size_t GetSessionGroupCount(){ return m_mapSessionInfo.size(); }

	Actions* GetActionRule( unsigned long id );
	Actions* GetSessionGroupRule( unsigned long id );
};

